/*
 *      Game.cpp
 *      
 *      Copyright 2008 William Hamrick <brick@brick-laptop>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */


//#include <allegro.h>
using namespace std;

class tile
{
	public:
		BITMAP *background;
		BITMAP *forground;
		bool walkable;
		int hasunit;
		bool lup, ldown, lleft, lright, eup, edown, eleft, eright;
};

class terrain
{
	public:
		BITMAP *map;
		BITMAP *buffer;
		vector<tile> tiles;
		int size;
		int height;
		int width;
		int camera[2];
		int tilewidth;
		int tileheight;
};

class mapobject
{
	public:
		BITMAP *pic;
		int unitid;
		int location[2];
		int size[2];
		int movingto[2];
};

mapobject cameraoob(terrain map1, mapobject player1)
{
	if (player1.location[0] > 0)
	{
		player1.location[0] = 0;
	}
	if (player1.location[0] < -map1.tilewidth * map1.size + player1.size[0])
	{
		player1.location[0] = -map1.tilewidth * map1.size + player1.size[0];
	}
	if (player1.location[1] > 0)
	{
		player1.location[1] = 0;
	}
	if (player1.location[1] < -map1.tileheight * map1.size + player1.size[1])
	{
		player1.location[1] = -map1.tileheight * map1.size + player1.size[1];
	}
	
	return player1;
}

mapobject startplayer(mapobject player1)
{
	player1.size[0] = 16;
	player1.size[1] = 16;
	player1.pic = create_bitmap(player1.size[0], player1.size[1]);
	clear_to_color(player1.pic, makecol(255,0,0));
	player1.location[0] = 0;
	player1.location[1] = 0;
	player1.movingto[0] = 0;
	player1.movingto[1] = 0;
	return player1;
};
